# import os
#
# import urllib3
#
# from tools.ReadJson import read_json
# import json
# from tools.Request_General import request_general
# from pyLib.YamlManage import YamlReader, PAR_CONFIG
#
# """
# 接口url
# """
# path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'data', 'tempSuperMarketData.json')
# file_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'data/image', 'template.zip')
# file_path_f = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'data/image', 'templatef.zip')
# file_path_img = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'data/image', 'upload_img.jpg')
# SPACE_PATH = read_json(path=path, app_name="space")
#
# template_host = YamlReader(file_path=PAR_CONFIG).get("template_host")
# host_list = [template_host.get("path"), template_host.get("user")]
# # login_list = find_csv_key("template_login")
#
# # 获取配置信息 *
# config = f'{host_list[0]}{host_list[1]}/api/sm/config'
# # 属性列表 *
# all_attribute = f'{host_list[0]}{host_list[1]}/api/sm/template/attribute/all-attribute'
# # 新增模板 **
# info_add = f'{host_list[0]}{host_list[1]}/internal/ware/manage/add'
# # 模板批量删除 **
# info_del = f'{host_list[0]}{host_list[1]}/internal/ware/manage/delete'
# # 模板下载记录 **
# download_record = f'{host_list[0]}{host_list[1]}/internal/ware/manage/download-record'
# # 编辑模板 **
# info_edit = f'{host_list[0]}{host_list[1]}/internal/ware/manage/edit'
# # 查看单个模板信息查询 **
# info_get = f'{host_list[0]}{host_list[1]}/internal/ware/manage/get'
# # 模板发布　**
# info_publish = f'{host_list[0]}{host_list[1]}/internal/ware/manage/publish'
# # 已发布模板查询 **
# publish_template = f'{host_list[0]}{host_list[1]}/internal/ware/manage/publish-template'
# # 模板下架 **
# info_rack = f'{host_list[0]}{host_list[1]}/internal/ware/manage/rack'
# # 推荐应用接口 *
# recommend_template = f'{host_list[0]}{host_list[1]}/api/sm/template/info/recommend/template'
# # 历史模板 **
# revisions_version = f'{host_list[0]}{host_list[1]}/internal/ware/manage/revisions-version'
# # 我的模板列表 **
# user_template = f'{host_list[0]}{host_list[1]}/internal/ware/manage/user-template'
# # 根据属性名称获取对应的值 *
# attribute_value = f'{host_list[0]}{host_list[1]}/api/sm/template/attribute/attribute-value'
# # 产品分类展示，默认每个属性取排序前三个 *
# attribute_attribute_value = f'{host_list[0]}{host_list[1]}/api/sm/template/attribute/attribute/value'
# # 查询固定应用信息 *
# app_store = f'{host_list[0]}{host_list[1]}/api/sm/template/info/app-store'
# # 根据属性信息与排序方式获取对应数量的模板 *
# hot_template = f'{host_list[0]}{host_list[1]}/api/sm/template/info/hot/template'
# # 行业介绍页根据属性信息与排序方式获取对应数量的模板 *
# introduce_hot_template = f'{host_list[0]}{host_list[1]}/api/sm/template/info/industry-introduce/hot/template'
# # 模板区域查询指定模板信息 *
# tab_template = f'{host_list[0]}{host_list[1]}/api/sm/template/info/tab-template'
# # 封面图片上传
# upload_pic = f'{host_list[0]}{host_list[1]}/internal/ware/manage/upload-picture'
#
# # 模板下载 **
# template_download = f'{host_list[0]}{host_list[1]}/internal/ware/download'
# # 空间ID查询应用 **
# download_app = f'{host_list[0]}{host_list[1]}/internal/ware/download/app'
# # 应用ID查询文件夹 **
# download_folder = f'{host_list[0]}{host_list[1]}/internal/ware/download/folder'
# # 模板下载结果 **
# download_result = f'{host_list[0]}{host_list[1]}/internal/ware/download/result'
# # 企业编码查询空间 **
# download_space = f'{host_list[0]}{host_list[1]}/internal/ware/download/space'
#
# # 属性筛选列表 *
# info_attribute = f'{host_list[0]}{host_list[1]}/api/sm/market/info/attribute'
# # 官网应用详情咨询 *
# info_consult = f'{host_list[0]}{host_list[1]}/api/sm/market/info/consult'
# # 模板信息详情并更新浏览量 *
# info_detail = f'{host_list[0]}{host_list[1]}/api/sm/market/info/detail'
# # 模板信息分页查询 *
# info_page = f'{host_list[0]}{host_list[1]}/api/sm/market/info/page'
# # 查询先胜云环境
# get_platforms = f'{host_list[0]}{host_list[1]}/internal/ware/download/get-platforms'
# # 模板市场登录 *
# # login = f'{login_list[0]}/oauth/login'
# # logout = f'{login_list[0]}/oauth/login/logout'
# # 查询用户详细信息接口 *
# get_userdetail = f'{host_list[0]}{host_list[1]}/api/sm/account/get-userdetail'
#
#
# class TEMP_MARKET(object):
#     @staticmethod
#     def config(header):
#         """
#         获取配置信息
#         """
#         r = request_general(method="GET", url=config, headers=header)
#         return r
#
#     @staticmethod
#     def all_attribute(header):
#         """
#         属性列表
#         """
#         r = request_general(method="GET", url=all_attribute, headers=header)
#         return r
#
#     @staticmethod
#     def attribute_value(header, par):
#         """
#         根据属性名称获取对应的值
#         """
#         r = request_general(method="GET", headers=header, params=par, url=attribute_value)
#         return r
#
#     @staticmethod
#     def attribute_attribute_value(header, par):
#         """
#         产品分类展示，默认每个属性取排序前三个
#         """
#         r = request_general(method="GET", headers=header, params=par, url=attribute_attribute_value)
#         return r
#
#     @staticmethod
#     def info_add(header, data, file=None):
#         """
#         新增模板
#         """
#         r = request_general(method="POST", url=info_add, headers=header, data=data, files=file)
#         return r
#
#     @staticmethod
#     def app_store(header, par):
#         """
#         查询固定应用信息
#         """
#         r = request_general(method="GET", url=app_store, headers=header, params=par)
#         return r
#
#     @staticmethod
#     def info_del(header, data):
#         """
#         模板批量删除
#         """
#         r = request_general(method="POST", url=info_del, headers=header, data=data)
#         return r
#
#     @staticmethod
#     def download_record(header, par):
#         """
#         模板下载记录
#         """
#         r = request_general(method="POST", url=download_record, headers=header, json=par)
#         return r
#
#     @staticmethod
#     def info_edit(header, data):
#         """
#         编辑模板
#         """
#         r = request_general(method="POST", url=info_edit, headers=header, data=data)
#         return r
#
#     @staticmethod
#     def info_get(header, par):
#         """
#         查看单个模板信息查询
#         """
#         r = request_general(method="GET", url=info_get, headers=header, params=par)
#         return r
#
#     @staticmethod
#     def hot_template(pay, header):
#         """
#         根据属性信息与排序方式获取对应数量的模板
#         """
#         r = request_general(method="POST", url=hot_template, headers=header, json=pay)
#         return r
#
#     @staticmethod
#     def introduce_hot_template(header, pay):
#         """
#         行业介绍页根据属性信息与排序方式获取对应数量的模板
#         """
#         r = request_general(method="POST", url=introduce_hot_template, headers=header, json=pay)
#         return r
#
#     @staticmethod
#     def info_publish(header, par):
#         """
#         模板发布
#         """
#         r = request_general(method="POST", url=info_publish, headers=header, params=par)
#         return r
#
#     @staticmethod
#     def publish_template(header, par):
#         """
#         已发布模板查询
#         """
#         r = request_general(method="POST", url=publish_template, headers=header, json=par)
#         return r
#
#     @staticmethod
#     def info_rack(header, par):
#         """
#         模板下架
#         """
#         r = request_general(method="POST", url=info_rack, headers=header, params=par)
#         return r
#
#     @staticmethod
#     def recommend_template(header):
#         """
#         推荐应用接口
#         """
#         r = request_general(method="GET", url=recommend_template, headers=header)
#         return r
#
#     @staticmethod
#     def revisions_version(header, par):
#         """
#         历史模板
#         """
#         r = request_general(method="GET", url=revisions_version, headers=header, params=par)
#         return r
#
#     @staticmethod
#     def tab_template(header):
#         """
#         模板区域查询指定模板信息
#         """
#         r = request_general(method="GET", url=tab_template, headers=header)
#         return r
#
#     @staticmethod
#     def user_template(header, par):
#         """
#         我的模板列表
#         """
#         r = request_general(method="POST", url=user_template, headers=header, json=par)
#         return r
#
#     @staticmethod
#     def template_download(header, pay):
#         """
#         模板下载
#         """
#         r = request_general(method="POST", url=template_download, headers=header, json=pay)
#         return r
#
#     @staticmethod
#     def download_app(header, par):
#         """
#         空间ID查询应用
#         """
#         r = request_general(method="GET", url=download_app, headers=header, params=par)
#         return r
#
#     @staticmethod
#     def download_folder(header, par):
#         """
#         应用id查询文件夹
#         """
#         r = request_general(method="GET", url=download_folder, headers=header, params=par)
#         return r
#
#     @staticmethod
#     def download_result(header, pay):
#         """
#         模板下载结果
#         """
#         r = request_general(method="POST", url=download_result, headers=header, json=pay)
#         return r
#
#     @staticmethod
#     def download_space(header, par):
#         """
#         企业编码查询空间
#         """
#         r = request_general(method="GET", url=download_space, headers=header, params=par)
#         return r
#
#     @staticmethod
#     def info_attribute(header):
#         """
#         属性筛选列表
#         """
#         r = request_general(method="GET", url=info_attribute, headers=header)
#         return r
#
#     @staticmethod
#     def info_detail(header, par):
#         """
#         模板信息详情并更新浏览量
#         """
#         r = request_general(method="GET", url=info_detail, headers=header, params=par)
#         return r
#
#     @staticmethod
#     def info_page(header, pay):
#         """
#         模板信息分页查询
#         """
#         r = request_general(method="POST", url=info_page, headers=header, json=pay)
#         return r
#
#     @staticmethod
#     def login_template(pay):
#         """
#         模板市场登录
#         """
#         urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
#         new_pay = json.dumps(pay)
#         r = request_general(method="POST", url="", data=new_pay, headers={"Content-Type": "application/json;charset=UTF-8"})
#         return r
#
#     @staticmethod
#     def upload_pic(header, data):
#         """
#         封面图片上传
#         """
#         r = request_general(method="POST", url=upload_pic, files=data, headers=header)
#         return r
#
#     @staticmethod
#     def info_consult(pay, header):
#         """
#         官网应用详情咨询
#         """
#         r = request_general(method="POST", url=info_consult, json=pay, headers=header)
#         return r
#
#     @staticmethod
#     def get_userdetail(header, query):
#         """
#         查询用户详细信息接口
#         """
#         r = request_general(method="GET", url=get_userdetail, params=query, headers=header)
#         return r
#
#     # @staticmethod
#     # def logout_template(header):
#     #     """
#     #     登出接口
#     #     """
#     #     r = request_general(method="POST", url=logout, headers=header)
#     #     return r
#
#     @staticmethod
#     def get_platforms(query, header):
#         """
#         查询先胜云环境
#         """
#         r = request_general(method="GET", url=get_platforms, params=query, headers=header)
#         return r
#
#
# if __name__ == '__main__':
#     login = TEMP_MARKET().login_template(
#         {"username": "leihong.song@proinnova.com.cn", "password": "985a14d57307be046f913c995db6caa2bdd3c64f0d5a004ac132b413f982cdaa"})
#     print(login.json())
